import request from '@/utils/request'

//枚举
enum Api {
  // 获取spulist列表数据
  getSpuListApi = '/admin/product',
  // 添加spuInfo数据
  saveSpuInfoApi = '/admin/product/saveSpuInfo',
  // 更新spuInfo数据
  updateSpuInfoApi = '/admin/product/updateSpuInfo',

  // 删除spuInfo数据
  deleteSpuInfoApi = '/admin/product/deleteSpu/{spuId}',
  // 所有的销售属性
  baseSaleAttrListApi = '/admin/product/baseSaleAttrList',
  // 所有的品牌列表数据
  trademarkListApi = '/admin/product/baseTrademark/getTrademarkList',
  // 根据spuId 重新获取获取对应的图片列表
  getSpuImageListApi = '/admin/product/spuImageList',
  // 根据spuId 重新获取销售属性列表
  getSpuSaleAttrListApi = '/admin/product/spuSaleAttrList'
}


//定义获取spu列表项数据的接口函数
export const reqGetSpuListData = (page:number,limit:number,category3Id:number) => {
  return request.get(Api.getSpuListApi+`/${page}/${limit}?category3Id=`+category3Id)
}

//获取品牌数据（下拉框）
export const reqGetAllTrademarkListData = ()=>{
  return request.get(Api. trademarkListApi)
}

//获取销售属性的数据（下拉框）
export const reqGetAllBaseSaleAttrListData = () => {
  return request.get(Api.baseSaleAttrListApi)
}

// 添加spuInfo
export const reqSaveSpuInfoData = (spuInfo) => {
  return request.post(Api.saveSpuInfoApi, spuInfo)
}

// 删除spuInfo数据
export const reqDeleteSpuInfo = (spuId: number) => {
  return request.post(Api.deleteSpuInfoApi + `/${spuId}`)
}

//根据spuId 获取图片列表
export const reqGetSpuImageListData = (spuId: number) => {
  return request.get(Api.getSpuImageListApi + `/${spuId}`)
}
// 根据spuId 获取基本销售属性及值
export const reqGetSpuSaleAttrListData = (spuId: number) => {
  return request.get(Api.getSpuSaleAttrListApi + `/${spuId}`)
}

// 更新spuInfo数据
export const reqUpdateSpuInfoApi = (spuInfo) => {
  return request.post(Api.updateSpuInfoApi,spuInfo)
}